#include "about.h"
#include "ui_about.h"
#include "commonfunction.h"
#include "pdfloader.h"

About::About(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::About)
{
    ui->setupUi(this);
    bdf = BllDataFlow::getInstance();
    pdfMgr = new PdfLoader(ui->scrollAreaIntroduction->widget());

    //Signals and Slots
    connect(bdf, &BllDataFlow::changeAboutPageIndexSignal, this, &About::changeAboutPageIndexSlot);
    connect(bdf, &BllDataFlow::retranslateUiSignal, this, &About::retranslateUiSlot);

    initWidget();
}

About::~About()
{
    delete ui;
}

void About::changeAboutPageIndexSlot(int index)
{
    ui->stackedWidget->setCurrentIndex(index);
}

void About::on_btnLocalInfo_clicked()
{
    bdf->changeAboutPageIndex(AboutPageIndex::LOCAL_INFO);
}

void About::on_btnManual_clicked()
{
    bdf->changeAboutPageIndex(AboutPageIndex::MANUAL);
    if (!ui->scrollAreaIntroduction->widget()->layout())
    {// 首次进入页面加载
        pdfMgr->load(ManualFile);
    }
}

void About::on_btnTechnique_clicked()
{
    bdf->changeAboutPageIndex(AboutPageIndex::TECHNIQUE);
}

void About::on_btnWebsite_clicked()
{
    bdf->changeAboutPageIndex(AboutPageIndex::WEBSITE);
}

void About::on_btnTips_clicked()
{
    bdf->changeAboutPageIndex(AboutPageIndex::TIPS);
}

void About::retranslateUiSlot()
{
    ui->retranslateUi(this);
}

void About::initIntroductionWidget()
{
}

void About::initManualWidget()
{
}

void About::initWidget()
{
    ui->stackedWidget->setCurrentIndex(0);
    ui->btnTips->hide();
    ui->btnTechnique->hide();
    initIntroductionWidget();
    initManualWidget();
}
